package com.gexiaobao.pigeon.ui.adapter

import androidx.appcompat.widget.AppCompatImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.TodayEnd
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.databinding.ItemLayoutClosingAuctionBinding

/**
 * @Author      : hxw
 * @Date        : 2024/11/11 16:32
 * @Describe    :
 */
class AdapterClosingAuction(data: ArrayList<TodayEnd>) :
    BaseQuickAdapter<TodayEnd, DataBindBaseViewHolder>(R.layout.item_layout_closing_auction, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: TodayEnd) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemLayoutClosingAuctionBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.setGone(R.id.llVideo, item.bkVideoCnt == 0 && item.gatherVideoCnt == 0)
        holder.setGone(R.id.ivProxyPriceState, item.proxyId == 0)
        val ivPigeonImage = holder.getView<AppCompatImageView>(R.id.ivPigeonImage)
        ImageLoaderManager.loadRoundImageTopOrEmpty(context, item.img, ivPigeonImage, 4, R.mipmap.app_icon_)

        val status = when (item.status) {
            1 -> "拍卖中"
            else -> ""
        }
        holder.setGone(R.id.tvItemClosingAuctionStatus,status.isEmpty())
        holder.setText(R.id.tvItemClosingAuctionStatus, status)
    }
}